import 'package:flutter/material.dart';
import 'package:happy_elf_app/store/config.dart';
import 'package:happy_elf_app/store/space.dart';
import 'package:happy_elf_app/utils/globalKey.dart';
import 'package:happy_elf_app/views/Space/evolution/index.dart';
import 'package:happy_elf_app/views/Space/house/index.dart';
import 'package:happy_elf_app/views/Space/together/index.dart';
import 'package:happy_elf_app/views/Space/widget/spaceBar.dart';

class Space extends StatefulWidget {
  const Space({super.key});

  @override
  State<Space> createState() => _SpaceState();
}

final SpaceDataProvider = Provider.of<SpaceData>(
  Global.navigatorKey.currentContext!,
  listen: false,
);

class _SpaceState extends State<Space> with SingleTickerProviderStateMixin {
  late AnimationController _controller;

  @override
  void initState() {
    super.initState();
    _controller = AnimationController(vsync: this);
  }

  @override
  void dispose() {
    _controller.dispose();
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    print('SpaceDataProvider.activeTab${SpaceDataProvider.activeTab}');
    return Consumer<SpaceData>(builder: (context, SpaceData, child) {
      return Scaffold(
        backgroundColor: Colors.white,
        body: Column(children: [
          Expanded(
            child: SpaceDataProvider.activeTab['value'] == 1
                ? Evolution(
                    // callback: () {
                    //   navState.navigateToHome()
                    // },
                    )
                : SpaceDataProvider.activeTab['value'] == 2
                    ? House()
                    : const Together(),
          ),
          SpaceBar()
        ]),
      );
    });
  }
}
